package com.karaoke.oksrv.service

import com.karaoke.oksrv.domain.RoomInfo
import com.karaoke.oksrv.domain.ScrollText
import com.karaoke.oksrv.domain.Song
import com.karaoke.oksrv.mapper.emedia.RoomMapper
import com.karaoke.oksrv.mapper.emedia.ScrollTextMapper
import com.karaoke.oksrv.mapper.master.SongMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/**
 * Created by allen on 2017/4/17.
 */
@Service
class RoomService
{
    fun getRoomInfo(roomId: String): RoomInfo
    {
        val result = RoomInfo()
        result.room = roomMapper.selectRoomInfo(roomId)
        if (result.room != null)
        {
            result.publicSongs = songMapper.selectPublicSongs()
            result.scrollTexts = scrollTextMapper.selectAll()
        }
        return result
    }

    fun getPublicSongs(): MutableList<Song>?
    {
        return songMapper.selectPublicSongs()
    }

    fun getScrollTexts(): MutableList<ScrollText>?
    {
        return scrollTextMapper.selectAll()
    }


    @Autowired lateinit var roomMapper: RoomMapper
    @Autowired lateinit var songMapper: SongMapper
    @Autowired lateinit var scrollTextMapper: ScrollTextMapper
}
